<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
  <template>
  <div class="sueSearch_box">
    <div class="sueSearch_title">
      <div class="search_box">
        <img src="@/assets/img/Back@3x.png" @click="returnHistoy" alt>
        <input type="text" :placeholder="placeholder" maxlength="20" v-model="searchInfo">
      </div>
      <i @click="returnHistoy">取消</i>
    </div>
    <scroll class="my_Solve_center_box">
      <div class="my_Solve_center">
        <div class="my_Solve_center_info" v-for="item in searchlist" :key="item.id">
          <img src="@/assets/img/Task1@3x.png" alt>
          <div class="my_Solve_center_info_title">
            <span>{{item.busiTypeName}}</span>
            <em>{{item.acceptTime | dateFormat('yyyy/MM/dd hh:mm:ss')}}</em>
          </div>
          <div class="my_Solve_center_info_center">
            <p>{{item.messageContent}}</p>
            <span>审批结果：</span>
            <span>{{item.opinionText}}</span>
          </div>
        </div>
      </div>
      <div
        v-if="!searchlist.length && searchInfo "
        class="sueSearch_none_list"
      >没有搜索到任何关于“{{searchInfo}}”的已处理任务</div>
      <div v-show="!searchlist.length && !searchInfo" class="sueSearch_none_list">{{searchName}}</div>
    </scroll>
  </div>
</template>
  
  <script>
import Scroll from "@/components/JoysScroll/JoysScroll";
import { myDOM } from "@/assets/js/utils.js";
export default {
  name: "MySearch",
  components: {
    Scroll
  },
  props: {
    placeholder: {
      type: String,
      default: "搜索已处理任务"
    },
    searchName: {
      type: String,
      default: "搜索以往处理任务"
    }
  },
  data() {
    return {
      searchInfo: "",
      searchlist: []
    };
  },
  methods: {
    searchInfoList() {
      this.$axios({
        url: "/joys-rest/joys-bpm/taskMessage/byCondition",
        method: "get",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN")
        },
        params: {
          appletName: this.searchInfo,
          workStatus: "ALREADY_WORK",
          pageIndex: 1,
          pageSize: 100
        }
      })
        .then(res => {
          this.searchlist = res.data.rows;
          console.log(this.searchlist, "qingq");
        })
        .catch(error => {
          console.log(error);
        });
    },
    // 请求图片
    // queryImg(id){
    //   return (
    //     "/joys-rest/joys-file/file/browse/one2one/" +
    //     id +
    //     "?AUTH-TOKEN=" +
    //     localStorage.getItem("AUTH-TOKEN")
    //   );
    // },
    returnHistoy() {
      this.$emit("childEvent");
      this.searchlist = "";
    }
  },
  created() {
    // 节流
    this.$watch(
      "searchInfo",
      myDOM.debounce(newQuery => {
        this.searchInfoList();
      }, 300)
    );
  }
};
</script>
  
  <style scoped lang="less">
.sueSearch_box {
  position: fixed;
  top: 0rem;
  bottom: 0.1rem;
  width: 100%;
  height: 100%;
  z-index: 300;
  background: #ffffff;
  .sueSearch_title {
    height: 0.44rem;
    width: 100%;
    background: #ffffff;
    box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
    position: relative;
    overflow: hidden;
    .search_box {
      position: absolute;
      top: 0rem;
      left: 0rem;
      width: 100%;
      line-height: 0.44rem;
      height: 0.44rem;
      img {
        width: 0.2rem;
        position: absolute;
        // left: 0.085rem;
        // top: 0.12rem;
        top: 0rem;
        left: 0rem;
        padding: 0.12rem 0.085rem;
      }
      input {
        padding-left: 0.1rem;
        height: 0.32rem;
        background: rgba(141, 141, 141, 0.05);
        font-family: Regular;
        font-size: 0.14rem;
        color: #001616;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
        margin-top: -0.05rem;
        margin-left: 0.36rem;
        width: 100%;
      }
      input::placeholder {
        font-family: Regular;
        font-size: 0.14rem;
        color: #c6c6c6;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
      }
    }
    i {
      display: block;
      height: 0.43rem;
      width: 0.63rem;
      line-height: 0.44rem;
      text-align: center;
      font-family: Regular;
      font-size: 0.14rem;
      color: #001616;
      letter-spacing: -0.34px;
      position: absolute;
      top: 0rem;
      right: 0rem;
      background: #ffffff;
    }
  }
  .my_Solve_center_box {
    overflow: hidden;
    height: 100%;
    background: #fbf9fe;
    // margin-bottom: 0.74rem;
    .my_Solve_center {
      // margin-top: 0.14rem;
      padding-bottom: 0.06rem;
      border-radius: 0.04rem;
      margin-bottom: 0rem;
      // margin: 0 0.32rem;
      .my_Solve_center_info {
        background: #ffffff;
        box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.09);
        border-radius: 0.04rem;
        margin: 0 0.16rem 0.1rem 0.16rem;
        // margin-bottom: 0.1rem;
        padding-bottom: 0.15rem;
        img {
          float: left;
          background: #d8d8d8;
          width: 0.18rem;
          height: 0.18rem;
          margin-left: 0.16rem;
        }
        .my_Solve_center_info_title {
          padding-left: 0.24rem;
          padding-right: 0.16rem;
          margin: 0 0.08rem;
          border-bottom: 1px #eeeeee solid;
          padding-top: 0.2rem;
          padding-bottom: 0.3rem;

          span {
            float: left;
            font-family: Mediums;
            font-size: 0.15rem;
            color: #202f1f;
            letter-spacing: -0.41px;
          }
          em {
            float: right;
            text-align: right;
            font-family: Regular;
            font-size: 0.13rem;
            color: #adadad;
            letter-spacing: -0.36px;
            text-align: right;
          }
        }
        .my_Solve_center_info_center {
          padding-left: 0.24rem;
          margin: 0 0.08rem;
          padding-top: 0.09rem;
          line-height: 0.2rem;
          padding-bottom: 0.05rem;
          p {
            font-family: Mediums;
            font-size: 0.15rem;
            color: #636363;
            letter-spacing: -0.41px;
          }
          span {
            display: inline-block;
            font-family: Regular;
            font-size: 0.13rem;
            color: #adadad;
            letter-spacing: -0.36px;
            text-align: right;
            line-height: 0.13rem !important;
          }
        }
      }
    }
    .my_Solve_center::before {
      content: "";
      display: block;
      height: 0.14rem;
      width: 100%;
    }
    .my_Solve_center::after {
      content: "";
      display: block;
      height: 0.44rem;
      width: 100%;
    }
  }
  .sueSearch_none_list {
    font-family: Regular;
    font-size: 0.13rem;
    color: rgba(0, 22, 22, 0.8);
    letter-spacing: 0;
    text-align: center;
    height: 100%;
    margin-top: -30%;
    padding-top: 60%;
    height: 100%;
    background: #fff;
  }
}
</style>